package reflect;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Scanner;

public class ReflectDemo1 {
    public static void main(String[] args) throws ClassNotFoundException {
        Class cls1 = String.class;
        Class cls2 = ArrayList.class;
        Class cls3 = int.class;

        Class cls4 = Class.forName("java.lang.String");
        Class cls5 = Class.forName("java.util.ArrayList");
        Scanner scan = new Scanner(System.in);
        System.out.println("名");
        String name = scan.nextLine();
        Class cls = Class.forName(name);

        System.out.println("获取类的完整限定名:"+cls.getName());
        System.out.println("获取类名:"+cls.getSimpleName());

        Package pack = cls.getPackage();
        System.out.println("获取包名:"+pack.getName());

        Method[] methods = cls.getMethods();
        System.out.println("一共:"+methods.length+"个");
        for (Method method : methods) {
            System.out.println(method.getName());
        }
    }
}
